var a = '123.1.txt';

var arr = a.split('.');
var name = arr[arr.length-1];
arr.length--;
console.log(arr.join('.'));
console.log(name)